//
//  ExpertDetailsExpert.m
//
//  Created by 啊  on 16/5/10
//  Copyright (c) 2016 __MyCompanyName__. All rights reserved.
//

#import "ExpertDetailsExpert.h"


NSString *const kExpertDetailsExpertEHeadUrl = @"eHeadUrl";
NSString *const kExpertDetailsExpertEName = @"eName";
NSString *const kExpertDetailsExpertECoverUrl = @"eCoverUrl";
NSString *const kExpertDetailsExpertECompany = @"eCompany";
NSString *const kExpertDetailsExpertEViewNum = @"eViewNum";
NSString *const kExpertDetailsExpertEMaxAge = @"eMaxAge";
NSString *const kExpertDetailsExpertEMinAge = @"eMinAge";
NSString *const kExpertDetailsExpertEDiscussion = @"eDiscussion";
NSString *const kExpertDetailsExpertEInfo = @"eInfo";
NSString *const kExpertDetailsExpertEAppellation = @"eAppellation";
NSString *const kExpertDetailsExpertEConsultancyNum = @"eConsultancyNum";
NSString *const kExpertDetailsExpertEId = @"eId";
NSString *const kExpertDetailsExpertEFavoriteNum = @"eFavoriteNum";
NSString *const kExpertDetailsExpertEBirthYear = @"eBirthYear";


@interface ExpertDetailsExpert ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end

@implementation ExpertDetailsExpert

@synthesize eHeadUrl = _eHeadUrl;
@synthesize eName = _eName;
@synthesize eCoverUrl = _eCoverUrl;
@synthesize eCompany = _eCompany;
@synthesize eViewNum = _eViewNum;
@synthesize eMaxAge = _eMaxAge;
@synthesize eMinAge = _eMinAge;
@synthesize eDiscussion = _eDiscussion;
@synthesize eInfo = _eInfo;
@synthesize eAppellation = _eAppellation;
@synthesize eConsultancyNum = _eConsultancyNum;
@synthesize eId = _eId;
@synthesize eFavoriteNum = _eFavoriteNum;
@synthesize eBirthYear = _eBirthYear;


+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
    return [[self alloc] initWithDictionary:dict];
}

- (instancetype)initWithDictionary:(NSDictionary *)dict
{
    self = [super init];
    
    // This check serves to make sure that a non-NSDictionary object
    // passed into the model class doesn't break the parsing.
    if(self && [dict isKindOfClass:[NSDictionary class]]) {
            self.eHeadUrl = [self objectOrNilForKey:kExpertDetailsExpertEHeadUrl fromDictionary:dict];
            self.eName = [self objectOrNilForKey:kExpertDetailsExpertEName fromDictionary:dict];
            self.eCoverUrl = [self objectOrNilForKey:kExpertDetailsExpertECoverUrl fromDictionary:dict];
            self.eCompany = [self objectOrNilForKey:kExpertDetailsExpertECompany fromDictionary:dict];
            self.eViewNum = [[self objectOrNilForKey:kExpertDetailsExpertEViewNum fromDictionary:dict] doubleValue];
            self.eMaxAge = [[self objectOrNilForKey:kExpertDetailsExpertEMaxAge fromDictionary:dict] doubleValue];
            self.eMinAge = [[self objectOrNilForKey:kExpertDetailsExpertEMinAge fromDictionary:dict] doubleValue];
            self.eDiscussion = [self objectOrNilForKey:kExpertDetailsExpertEDiscussion fromDictionary:dict];
            self.eInfo = [self objectOrNilForKey:kExpertDetailsExpertEInfo fromDictionary:dict];
            self.eAppellation = [self objectOrNilForKey:kExpertDetailsExpertEAppellation fromDictionary:dict];
            self.eConsultancyNum = [[self objectOrNilForKey:kExpertDetailsExpertEConsultancyNum fromDictionary:dict] doubleValue];
            self.eId = [[self objectOrNilForKey:kExpertDetailsExpertEId fromDictionary:dict] doubleValue];
            self.eFavoriteNum = [[self objectOrNilForKey:kExpertDetailsExpertEFavoriteNum fromDictionary:dict] doubleValue];
            self.eBirthYear = [self objectOrNilForKey:kExpertDetailsExpertEBirthYear fromDictionary:dict];

    }
    
    return self;
    
}

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:self.eHeadUrl forKey:kExpertDetailsExpertEHeadUrl];
    [mutableDict setValue:self.eName forKey:kExpertDetailsExpertEName];
    [mutableDict setValue:self.eCoverUrl forKey:kExpertDetailsExpertECoverUrl];
    [mutableDict setValue:self.eCompany forKey:kExpertDetailsExpertECompany];
    [mutableDict setValue:[NSNumber numberWithDouble:self.eViewNum] forKey:kExpertDetailsExpertEViewNum];
    [mutableDict setValue:[NSNumber numberWithDouble:self.eMaxAge] forKey:kExpertDetailsExpertEMaxAge];
    [mutableDict setValue:[NSNumber numberWithDouble:self.eMinAge] forKey:kExpertDetailsExpertEMinAge];
    [mutableDict setValue:self.eDiscussion forKey:kExpertDetailsExpertEDiscussion];
    [mutableDict setValue:self.eInfo forKey:kExpertDetailsExpertEInfo];
    [mutableDict setValue:self.eAppellation forKey:kExpertDetailsExpertEAppellation];
    [mutableDict setValue:[NSNumber numberWithDouble:self.eConsultancyNum] forKey:kExpertDetailsExpertEConsultancyNum];
    [mutableDict setValue:[NSNumber numberWithDouble:self.eId] forKey:kExpertDetailsExpertEId];
    [mutableDict setValue:[NSNumber numberWithDouble:self.eFavoriteNum] forKey:kExpertDetailsExpertEFavoriteNum];
    [mutableDict setValue:self.eBirthYear forKey:kExpertDetailsExpertEBirthYear];

    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (NSString *)description 
{
    return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}

#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict
{
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}


#pragma mark - NSCoding Methods

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];

    self.eHeadUrl = [aDecoder decodeObjectForKey:kExpertDetailsExpertEHeadUrl];
    self.eName = [aDecoder decodeObjectForKey:kExpertDetailsExpertEName];
    self.eCoverUrl = [aDecoder decodeObjectForKey:kExpertDetailsExpertECoverUrl];
    self.eCompany = [aDecoder decodeObjectForKey:kExpertDetailsExpertECompany];
    self.eViewNum = [aDecoder decodeDoubleForKey:kExpertDetailsExpertEViewNum];
    self.eMaxAge = [aDecoder decodeDoubleForKey:kExpertDetailsExpertEMaxAge];
    self.eMinAge = [aDecoder decodeDoubleForKey:kExpertDetailsExpertEMinAge];
    self.eDiscussion = [aDecoder decodeObjectForKey:kExpertDetailsExpertEDiscussion];
    self.eInfo = [aDecoder decodeObjectForKey:kExpertDetailsExpertEInfo];
    self.eAppellation = [aDecoder decodeObjectForKey:kExpertDetailsExpertEAppellation];
    self.eConsultancyNum = [aDecoder decodeDoubleForKey:kExpertDetailsExpertEConsultancyNum];
    self.eId = [aDecoder decodeDoubleForKey:kExpertDetailsExpertEId];
    self.eFavoriteNum = [aDecoder decodeDoubleForKey:kExpertDetailsExpertEFavoriteNum];
    self.eBirthYear = [aDecoder decodeObjectForKey:kExpertDetailsExpertEBirthYear];
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{

    [aCoder encodeObject:_eHeadUrl forKey:kExpertDetailsExpertEHeadUrl];
    [aCoder encodeObject:_eName forKey:kExpertDetailsExpertEName];
    [aCoder encodeObject:_eCoverUrl forKey:kExpertDetailsExpertECoverUrl];
    [aCoder encodeObject:_eCompany forKey:kExpertDetailsExpertECompany];
    [aCoder encodeDouble:_eViewNum forKey:kExpertDetailsExpertEViewNum];
    [aCoder encodeDouble:_eMaxAge forKey:kExpertDetailsExpertEMaxAge];
    [aCoder encodeDouble:_eMinAge forKey:kExpertDetailsExpertEMinAge];
    [aCoder encodeObject:_eDiscussion forKey:kExpertDetailsExpertEDiscussion];
    [aCoder encodeObject:_eInfo forKey:kExpertDetailsExpertEInfo];
    [aCoder encodeObject:_eAppellation forKey:kExpertDetailsExpertEAppellation];
    [aCoder encodeDouble:_eConsultancyNum forKey:kExpertDetailsExpertEConsultancyNum];
    [aCoder encodeDouble:_eId forKey:kExpertDetailsExpertEId];
    [aCoder encodeDouble:_eFavoriteNum forKey:kExpertDetailsExpertEFavoriteNum];
    [aCoder encodeObject:_eBirthYear forKey:kExpertDetailsExpertEBirthYear];
}

- (id)copyWithZone:(NSZone *)zone
{
    ExpertDetailsExpert *copy = [[ExpertDetailsExpert alloc] init];
    
    if (copy) {

        copy.eHeadUrl = [self.eHeadUrl copyWithZone:zone];
        copy.eName = [self.eName copyWithZone:zone];
        copy.eCoverUrl = [self.eCoverUrl copyWithZone:zone];
        copy.eCompany = [self.eCompany copyWithZone:zone];
        copy.eViewNum = self.eViewNum;
        copy.eMaxAge = self.eMaxAge;
        copy.eMinAge = self.eMinAge;
        copy.eDiscussion = [self.eDiscussion copyWithZone:zone];
        copy.eInfo = [self.eInfo copyWithZone:zone];
        copy.eAppellation = [self.eAppellation copyWithZone:zone];
        copy.eConsultancyNum = self.eConsultancyNum;
        copy.eId = self.eId;
        copy.eFavoriteNum = self.eFavoriteNum;
        copy.eBirthYear = [self.eBirthYear copyWithZone:zone];
    }
    
    return copy;
}


@end
